import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

public class oneServlet extends HttpServlet {

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        // 1. 通过请求对象, 读取{请求行}中的{URL}信息
        // request.getRequestURL(), 读取URL信息, 返回一个StringBuffer
        String url = request.getRequestURL().toString();
        // 2. 通过请求对象, 读取{请求行}中{method}信息
        // request.getMethod(), 返回值是Http请求的方法名
        String method = request.getMethod();
        // 3. 通过请求对象, 读取{请求行}中{URI}信息
        // request.getRequestURI(), 读取URI信息, 返回结果为一个String
        String uri = request.getRequestURI();

        System.out.println("URL = " + url);
        System.out.println("method = " + method);
        System.out.println("URI = " + uri);
    }

}
